/**
 * 跑马灯组件
 */
var SpeakerUnit = Unit.extend({
    /**
     * 运行时间
     * @private
     */
    _duration: 20,
    _ccsFileName: res.SpeakerUnit_json,

    refreshData: function () {
        if (window['mainlayer_3200_data']) {
            this._onSpeaker({content: window['mainlayer_3200_data']})
        }
    },

    _initNetworkListeners: function () {
        Unit.prototype._initNetworkListeners.call(this);
        this._networkListeners = {
            Speaker: '_onSpeaker'
        };
    },
    /**
     *
     * @private
     */
    _onSpeaker: function (data) {
        if (!data.content) {
            return;
        }
        if (data) {
            window['mainlayer_3200_data'] = data.content;
        }

        var content = data.content;
        if (window.inReview || window.inBanShu) {
            content = '文明游戏,快乐人生! (*^__^*) ';
        }
        if (isNullString(content)) {
            return;
        }
        if (!this._rootNode) {
            return;
        }
        var panel = this._nodeList['panel'];
        var text = new ccui.Text();
        text.setFontSize(26);
        text.setColor(cc.color(220, 218, 203));
        text.setAnchorPoint(cc.p(0, 0));
        //text.enableOutline(cc.color(0, 0, 0), 1);
        panel.removeAllChildren();
        panel.addChild(text);
        text.setString(content);
        text.x = panel.getContentSize().width;
        var action = cc.sequence(
            cc.moveTo(this._duration, -text.getVirtualRendererSize().width, -3),
            cc.callFunc(function () {
                text.x = panel.getContentSize().width;
            })
        ).repeatForever();
        text.runAction(action);
    }
});